#region Using

using System;
using System.Xml;
using System.IO;
using System.Collections.Generic;
using System.Collections.Specialized;
using BlogEngine.Core;
using BlogEngine.Core.Providers.EloqueraProvider.Db;

#endregion

namespace BlogEngine.Core.Providers {
    /// <summary>
    /// A storage provider for BlogEngine that uses XML files.
    /// <remarks>
    /// To build another provider, you can just copy and modify
    /// this one. Then add it to the web.config's BlogEngine section.
    /// </remarks>
    /// </summary>
    public partial class EloqueraBlogProvider : BlogProvider {

        /// <summary>
        /// Loads the ping services.
        /// </summary>
        /// <returns></returns>
        public override StringCollection LoadPingServices() {
            EqPingServices pings = (EqPingServices)EqDb.ExecuteScalar("select EqPingServices");
            StringCollection col = new StringCollection();
            if (pings != null) {
                col.AddRange(pings.Services);
            }
            return col;
        }

        /// <summary>
        /// Saves the ping services.
        /// </summary>
        /// <param name="services">The services.</param>
        public override void SavePingServices(StringCollection services) {
            EqPingServices pings = (EqPingServices)EqDb.ExecuteScalar("select EqPingServices");
            if (pings == null) {
                pings = new EqPingServices();
            }
            List<string> lstServices = new List<string>();
            foreach (var ser in services) {
                lstServices.Add(ser);
            }
            pings.Services = lstServices.ToArray();
            EqDb.Store(pings);
        }
    }
}
